package com.hk.housekeeping.order.service.impl;

import com.hk.housekeeping.order.dao.impl.ItemDaoImpl;
import com.hk.housekeeping.order.entity.OrderItem;
import com.hk.housekeeping.order.service.ItemPageServ;
import com.hk.housekeeping.order.utils.PageUtils;

import java.sql.SQLException;
import java.util.List;

public class ItemPageServImpl implements ItemPageServ {
    private ItemDaoImpl itemDao = new ItemDaoImpl();

    @Override
    public PageUtils<List<OrderItem> > getItemPageList(String sid, int page, int pageSize) throws SQLException {
        List<OrderItem> itemList = itemDao.getItemPageList(sid, (page - 1) * pageSize, pageSize);
        int totalCount = itemDao.getTotalItemNum(sid);
        PageUtils<List<OrderItem>> pageObj = new PageUtils<>();
        pageObj.setTotalCount(totalCount);
        pageObj.setData(itemList);
        pageObj.setCurrentPage(page);
        return pageObj;
    }
}
